<?php 
if(!isset($_SESSION)) 
	{ 
		session_start(); 
	}
$lang = $_SESSION['lang'];
require_once('calendar/classes/tc_calendar.php');
if (empty($lang) || $lang == "EN") {
	include "value/value_en.php";
} else if($lang == "VN") {
	include "value/value_vn.php";
}
else {
	include "value/value_kr.php";
}
include 'generallibraries/funcs.php';
include 'operations/connection.php';	
$page=$_GET['page'];

$sqlTax = generalFunctions::listTax($_SESSION['lang']);
$mangTax=mysql_query($sqlTax);
if(isset($_REQUEST["idcus"])){
	if($_REQUEST["idcus"]!=""){
		$_SESSION['idcusupdel']=$_REQUEST["idcus"];
		$hamsort=" where ac_customer.CustomerID='".$_REQUEST["idcus"]."'";
		$sql=generalFunctions::listCustomer("ac_customer.CustomerID,ac_customer.CustomerName,ac_customer.Agent,ac_customer.IDNumber,ac_customer.Phone,ac_customer.Website,ac_customer.Description,ac_customer.Fax,ac_customer.Address,ac_customer.Email,ac_customer.Mobile,ac_customer.CompanyType1,ac_customer.CompanyType2,ac_customer.CompanyType3,ac_customer.TaxID,ac_customer.CreatedDate,ac_customer.Activest",$hamsort);
		$m=mysql_query($sql);
		if(mysql_num_rows($m)>0){
			while($row = mysql_fetch_array($m)){
				$fromdate=$row[CreatedDate];
				$_REQUEST["txtdes"]=$row[Description];
				$_REQUEST["txtmobile"]=$row[Mobile];
				$_REQUEST["txtphone"]=$row[Phone];
				$_REQUEST["txtfax"]=$row[Fax];
				$_REQUEST["txtcomname"]=$row[CustomerName];
				$_REQUEST["txtaddress"]=$row[Address];
				$_REQUEST["txtwebsite"]=$row[Website];
				$_REQUEST["txtcomtype121"]=$row[CompanyType1];
				$_REQUEST["txtcomtype122"]=$row[CompanyType2];
				$_REQUEST["txtcontactperson"]=$row[Agent];
				$_REQUEST["txtmail"]=$row[Email];
				$_REQUEST["txtcomnum"]=$row[IDNumber];
		
				$_REQUEST["cbtax"]=$row[TaxID];
				$_REQUEST["rtype"]=$row[CompanyType3];
				$_REQUEST["abc"]=$row[Activest];
			}
			$_SESSION['thucthi']="updel";
		}else{
			$_REQUEST['rtype']="Purchase";
			$_REQUEST['abc']="1";
			$fromdate=date("Y-m-d");
			$_REQUEST["txtdes"]="";
			$_REQUEST["txtmobile"]="";
			$_REQUEST["txtphone"]="";
			$_REQUEST["txtfax"]="";
			$_REQUEST["txtcomname"]="";
			$_REQUEST["txtaddress"]="";
			$_REQUEST["txtwebsite"]="";
			$_REQUEST["txtcomtype121"]="";
			$_REQUEST["txtcomtype122"]="";
			$_REQUEST["txtcontactperson"]="";
			$_REQUEST["txtmail"]="";
			$_REQUEST["txtcomnum"]="";
		}
	}else{
		$_REQUEST['rtype']="Purchase";
		$_REQUEST['abc']="1";
		$fromdate=date("Y-m-d");
		$_REQUEST["txtdes"]="";
		$_REQUEST["txtmobile"]="";
		$_REQUEST["txtphone"]="";
		$_REQUEST["txtfax"]="";
		$_REQUEST["txtcomname"]="";
		$_REQUEST["txtaddress"]="";
		$_REQUEST["txtwebsite"]="";
		$_REQUEST["txtcomtype121"]="";
		$_REQUEST["txtcomtype122"]="";
		$_REQUEST["txtcontactperson"]="";
		$_REQUEST["txtmail"]="";
		$_REQUEST["txtcomnum"]="";
	}
}else{
	$_REQUEST['rtype']="Purchase";
	$_REQUEST['abc']="1";
	$fromdate=date("Y-m-d");
	$_REQUEST["txtdes"]="";
	$_REQUEST["txtmobile"]="";
	$_REQUEST["txtphone"]="";
	$_REQUEST["txtfax"]="";
	$_REQUEST["txtcomname"]="";
	$_REQUEST["txtaddress"]="";
	$_REQUEST["txtwebsite"]="";
	$_REQUEST["txtcomtype121"]="";
	$_REQUEST["txtcomtype122"]="";
	$_REQUEST["txtcontactperson"]="";
	$_REQUEST["txtmail"]="";
	$_REQUEST["txtcomnum"]="";
}

?>
<link href="calendar/calendar.css" rel="stylesheet" type="text/css" />

<script language="javascript" src="calendar/calendar.js"></script>
<div class="head_info"><?php echo $l_customer;?></div>
			<div style="margin:5px 5px 10px 7px">
			<div style="text-align: left;font-size:12px;font-weight:bold" id="viewdate">
				<table style="padding-bottom:10px;padding-top:5px;margin:center;width:100%;">
									<tr>
                                    	<td>
                                        	<div style="width:100%;text-align:center;">
                                            	<input id="AddNew" onclick="addnew('<?=$_SESSION['thucthi']?>','<?php echo $_SESSION['checknamecus'];?>');" name="AddNew" style="margin-right:3px" type="button" value="<?php echo $l_add;?>" class="btnupbg btnupload" />
                                                <input id="Update" onclick="update('<?=$_SESSION['thucthi']?>','<?=$_SESSION['idcusupdel']?>','<?php echo $_SESSION['checknamecus'];?>',<?=$page?>);" name ="Update" style="margin-right:3px" type="button" value="<?php echo $l_update;?>" class="btnupbg btnupload" />
                                                <input id="Delete" onclick="deleteone('<?=$_SESSION['thucthi']?>','<?=$_REQUEST["abc"]?>','<?=$_SESSION['idcusupdel']?>',<?=$page?>);" name ="Delete" style="margin-right:3px" type="button" value="<?php echo $l_delete;?>" class="btnupbg btnupload" />
                                                <input id="ResetNew" name="ResetNew" type="button" value="<?php echo $l_reset;?>" class="btnupbg btnupload" onclick="resetvalue1(document.accsetupcus.list);"/>
                                            </div>
                                        </td>
                                    </tr>
                                    <tr>
                                    	<td>
                                        	<div style="width:100%;text-align:center;color:green;font-weight: bold;padding-top: 5px;padding-bottom: 5px;" id="viewketquathucthi">
                                            </div>
                                        </td>
                                    </tr>
				</table>
				<table>
					<tr>
						<td ><span><b><?php echo $l_Transactionregistrydate;?> :</b></span></td>
						<td style="padding-left:3px;">
							<?php
							  $myCalendar1 = new tc_calendar("trandate", true);
							  $myCalendar1->setIcon("calendar/images/iconCalendar.gif");
							  $d=split('-',$fromdate,3);
							 
							  $myCalendar1->setDate($d[2],$d[1],$d[0]);
							  $myCalendar1->setPath("calendar/");
							  $myCalendar1->setYearInterval(2010, 2015);
							  $myCalendar1->dateAllow('2010-01-01', '2015-12-31');
							  //$myCalendar1->setHeight(350);
							  //$myCalendar1->autoSubmit(true, "form1");
							  //$myCalendar1->setSpecificDate(array("2011-04-01", "2011-04-13", "2011-04-25"), 0, 'month');
							  $myCalendar1->setOnChange("myChanged('test')");
							  //$myCalendar->rtl = true;
							  $myCalendar1->writeScript();
		
							  //echo $myCalendar1->getDate();
							  
						  ?>
						</td>
					</tr>
				</table>
 			</div>
			<div style="margin: 10px 7px 5px 3px; color: #508E21; border-bottom: 1px dotted silver"> <?php echo $l_CompanyDetails;?> </div>
			<table style="border-bottom: 1px dotted silver; padding:10px 5px" width="100%">
                                  <tr>
                                    <td class="tdfirst"><?php echo $l_company_name;?>:</td>
                                    <td><input type="text" onkeypress="return enterTable(event,this.id);" onchange="checkname1(this.value,'<?=$_REQUEST["idcus"]?>');" value="<?=$_REQUEST['txtcomname']?>" name="txtcomname" id="txtcomname" class="in_testfield" style="width:516px;" /></td>
                                  </tr>
                                  <tr>
                                  	<td></td>
                                  	<td id="viewerr" style="color:red; font-weight: bold;"><input type="hidden" id="lienngo" value="<?=$_SESSION[checknamecus]?>"/></td>
                                  </tr>
                                  <tr>
                                    <td class="tdfirst"><?php echo $l_address;?>:</td>
                                    <td><input type="text" onkeypress="return enterTable(event,this.id);" value="<?=$_REQUEST['txtaddress']?>" name="txtaddress" id="txtaddress" class="in_testfield" style="width:516px" /></td>
                                  </tr>
                                  <tr>
                                    <td class="tdfirst"><?php echo $l_Website;?>:</td>
                                    <td><input type="text" onkeypress="return enterTable(event,this.id);" value="<?=$_REQUEST['txtwebsite']?>" name="txtwebsite" id="txtwebsite" class="in_testfield" style="width:516px" /><span style="font-size:11px; color:#424242; padding-left:10px">eg. http://www.elisoft.com, http://www.google.com</span> </td>
                                  </tr>
                                  <tr>
                                    <td class="tdfirst"><?php echo $l_CompanyNumber;?>:</td>
                                    <td><input type="text" onkeypress="return enterTable(event,this.id);" value="<?=$_REQUEST['txtcomnum']?>" name="txtcomnum" id="txtcomnum" class="in_testfield" style="float:left;" />
                                    	<span style="background: #E8E8E8;float: left;margin-left: 3px;padding: 5px;width: 80px;"> <?php echo $l_tax;?> : </span>
	                                      <select id="cbtax" onkeypress="return enterTable(event,this.id);" name="cbtax" style="width:120px; height:22px; margin-left:3px">
	                                        <?php 
	                                        	if(mysql_num_rows($mangTax)>0){
	                                        		while($row= mysql_fetch_array($mangTax)){
	                                        			?>
	                                        			<option value="<?=$row[TaxID];?>"
	                                        				<?php 
	                                        					if($_REQUEST['cbtax']==$row[TaxID]){
	                                        						?>
	                                        						selected="selected"
	                                        						<?php 
	                                        					}
	                                        				?>
	                                        			><?php echo $row[TaxName];?></option>
	                                        			<?php 
	                                        		}
	                                        	}
	                                        ?>
	                                      </select>
                                    </td>
                                  </tr>
                                  <tr>
                                    <td class="tdfirst"><?php echo $l_Companytype12;?>:</td>
                                    <td><input type="text" onkeypress="return enterTable(event,this.id);" value="<?=$_REQUEST['txtcomtype121']?>" name="txtcomtype121" id="txtcomtype121" class="in_testfield" style="width:250px" />
                                      /
                                      <input style="width:250px" onkeypress="return enterTable(event,this.id);" type="text" value="<?=$_REQUEST['txtcomtype122']?>" name="txtcomtype122" id="txtcomtype122"  class="in_testfield" /></td>
                                  </tr>
                                  <tr>
                                    <td class="tdfirst"><?php echo $l_Companytype;?>:</td>
                                    <td>
                                      	<table width="80%">
                                      		<tr>
                                      			<td><input type="radio" id="rtype" onkeypress="return enterTable(event,this.id);" name="rtype"  value="Purchase" <?php if ($_REQUEST["rtype"]=="Purchase") echo "checked";?> /><?php echo $l_Buys;?></td>
                                      			<td><input type="radio" id="rtype" name="rtype"  onkeypress="return enterTable(event,this.id);" value="Sale" <?php if ($_REQUEST["rtype"]=="Sale") echo "checked";?> /><?php echo $l_Sales;?></td>
                                      			<td><input type="radio" id="rtype" name="rtype"  onkeypress="return enterTable(event,this.id);" value="CaHai" <?php if ($_REQUEST["rtype"]=="CaHai") echo "checked";?> /><?php echo $l_Buyandsale;?></td>
                                      			<td><input type="radio" id="rtype" name="rtype"  onkeypress="return enterTable(event,this.id);" value="CreditCard" <?php if ($_REQUEST["rtype"]=="CreditCard") echo "checked";?> /><?php echo $l_Creditcard;?></td>
                                      		</tr>
                                      	</table>
                                     </td>
                                  </tr>
                                </table>
								 <div style="margin: 10px 7px 5px 3px; color: #508E21; border-bottom: 1px dotted silver"> <?php echo $l_Contactperson;?> </div>
			<table style="border-bottom: 1px dotted silver; padding:10px 5px" width="100%">
                                 <tr>
                                    <td class="tdfirst"><?php echo $l_Contactperson;?>:</td>
                                    <td><input type="text" onkeypress="return enterTable(event,this.id);" value="<?=$_REQUEST['txtcontactperson']?>" name="txtcontactperson" id="txtcontactperson" class="in_testfield" style="width:516px" /></td>
                                  </tr>
                                  <tr>
                                    <td class="tdfirst"><?php echo $l_email;?>:</td>
                                    <td><input type="text" onkeypress="return enterTable(event,this.id);" value="<?=$_REQUEST['txtmail']?>" name="txtmail" id="txtmail" class="in_testfield" style="float:left;width:280px;" />
                                    	<span style="background: #E8E8E8;float: left;margin-left: 3px;padding: 5px;width: 70px;"> <?php echo $l_Fax;?> : </span>
                                    	<input type="text" onkeypress="return enterTable(event,this.id);" value="<?=$_REQUEST['txtfax']?>" name="txtfax" id="txtfax" class="in_testfield" style="width:148px; margin-left:3px"/>
                                    </td>
                                  </tr>
								  <tr>
                                    <td class="tdfirst"><?php echo $l_phone;?>:</td>
                                    <td><input type="text" onkeypress="return enterTable(event,this.id);" value="<?=$_REQUEST['txtphone']?>" name="txtphone" id="txtphone" class="in_testfield" style="width:200px;float:left;" />
                                    	<span style="background: #E8E8E8;float: left;margin-left: 3px;padding: 5px;width: 100px;"> <?php echo $l_mobile;?> : </span>
                                    	<input type="text" onkeypress="return enterTable(event,this.id);" value="<?=$_REQUEST['txtmobile']?>" name="txtmobile" id="txtmobile" class="in_testfield" style="width:198px; margin-left:3px"  />
                                    </td>
                                  </tr>
								  <tr>
                                    <td class="tdfirst"><?php echo $l_description;?>:</td>
                                    <td><textarea name="txtdes" onkeypress="return enterTable(event,this.id);" id="txtdes" style="width:515px; height:50px" rows="4" cols="4"><?=$_REQUEST["txtdes"]?></textarea></td>
                                  </tr>
								 </table>
								<table bgcolor="#e8e8e8" width="100%" style="padding:20px 10px">
                                	<tr>
                                    	<td width="180"><?php echo $l_Activestatus;?></td>
                                        <td><input type="radio"  name="abc" value="1" <?php if ($_REQUEST["abc"]=="1") echo "checked";?> /> <?php echo $l_yes;?> <input type="radio" name="abc"  value="0" <?php if ($_REQUEST["abc"]=="0") echo "checked";?>/> <?php echo $l_No;?></td>
                                    </tr>
                                    
                                </table>
								</div>
								<?php mysql_close($connection);?>